package com.example.maomao.controller;

import com.example.maomao.mapper.AboutMapper;
import com.example.maomao.model.About;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class GuanliController {

    @Autowired
    AboutMapper aboutMapper;

    @GetMapping("/guanli")
    public String guanLi(Model model){
       List<About> about;
        about = aboutMapper.findAll();
        model.addAttribute("about", about);
        return "guanli";
    }

    @GetMapping("/admin")
    public String admin(@RequestParam(name = "id") int id){
        aboutMapper.delete(id);

        return "redirect:/guanli";
    }


}
